package cn.team.Util;

import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;

import java.util.Random;

public class MailUtil {
    public static String generateVerificationCode() {
        Random random = new Random();
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < 6; i++) {
            code.append(random.nextInt(10));
        }
        return code.toString();
    }

    public static void sendMailMessage(MailSender mailSender,SimpleMailMessage mailMessage,String subject,
                                String msg,String username){
        mailMessage.setSubject(subject);
        mailMessage.setText(msg);
        mailMessage.setFrom("3331885126@qq.com");
        mailMessage.setTo(username);
        mailSender.send(mailMessage);
    }
}
